<template>
  <div>
    <a-drawer
      title="Basic Drawer"
      placement="right"
      :closable="false"
      @close="onClose"
      :visible="visible"
    >
      <template v-slot:handle>
        <div class="setting-drawer-handle" @click="visible = !visible">
          <a-icon :type="visible ? 'close' : 'setting'"></a-icon>
        </div>
      </template>
      <h3>整体风格定制</h3>
      <!--  change 默认第一个参数传的是 event，所以想要传递其他参数，就这样写-->
      <a-radio-group
        name="radioGroup"
        :value="navTheme"
        @change="e => handleChange('navTheme', e.target.value)"
      >
        <a-radio value="dark">黑色</a-radio>
        <a-radio value="light">白色</a-radio>
      </a-radio-group>
      <h3>导航模式</h3>
      <a-radio-group
        name="radioGroup"
        :value="navLayout"
        @change="e => handleChange('navLayout', e.target.value)"
      >
        <a-radio value="left">左侧</a-radio>
        <a-radio value="top">顶部</a-radio>
      </a-radio-group>
    </a-drawer>
  </div>
</template>
<script>
export default {
  name: "SettingDrawer",
  data() {
    return {
      visible: false
    };
  },
  computed: {
    navTheme() {
      return this.$route.query.navTheme || "dark";
    },
    navLayout() {
      return this.$route.query.navLayout || "left";
    }
  },
  methods: {
    showDrawer() {
      this.visible = true;
    },
    onClose() {
      this.visible = false;
    },
    handleChange(type, value) {
      // console.log(type, value,this.$router,this.$route)
      this.$router.push({
        path: "/",
        query: { ...this.$route.query, [type]: value }
      });
    }
  }
};
</script>
<!-- 这里使用单独的文件来管理less 可以使用UI库定制的主题变量 这样可以可以动态的修改主题色-->
<style lang="less" src="./SettingDrawer.less"></style>
